//https://github.com/luohaha/Chinese-uvbook/blob/master/source/basics_of_libuv.md

#include <stdio.h>
#include <stdlib.h>
#include "uv.h"
#include <iostream>
#include "queue.h"

class Test
{
public:
	char		m1;
	int		m2; 
	short		m3;
};

enum eTest
{
	eTest1,
	eTest2,
	eTest3,
	eTest4,
	eTest5,
	eTest6,
	eTest7,
	eTest8,
	eTest9,
	eTest10,
};

int64_t counter = 0;

void wait_for_a_while(uv_idle_t* handle)
{
	counter++;

	if (counter >= 10e6)
		uv_idle_stop(handle);
}

int main(int argc, char* argv[]) 
{
	std::cout << PrintMacro(UV_LOOP_WATCHER_DEFINE) << std::endl;

	std::cout << "sizeof(unsigned int): " << sizeof(unsigned int) << std::endl;

	

	Test tTest;
	printf("offset of m1 in Test: %d\n", offsetof(Test, m1));
	printf("offset of m2 in Test: %d\n", offsetof(Test, m2));
	printf("offset of m3 in Test: %d\n", offsetof(Test, m3));
	//int t2 = 0;
	//printf("offset of t2 in Test: %d\n", offsetof(Test, t2));
	QUEUE queue;
	printf( "offset of queue in uv_async_t: %d\n", offsetof(uv_async_t, queue) );

	
	
	
	uv_idle_t idler;

	uv_idle_init(uv_default_loop(), &idler);
	uv_idle_start(&idler, wait_for_a_while);

	printf("Idling...\n");
	uv_run(uv_default_loop(), UV_RUN_DEFAULT);

	uv_loop_close(uv_default_loop());

	return 0;
}